package engine.parsers.impl;

import engine.content.IContent;
import engine.parsers.IParser;
import engine.services.IContentService;


public class DilbertParser  implements IParser{

	// returns the url for the picture after parsing the original url
	public IContent parse(IContent urlContent, IContentService contentService) throws Exception {
		String urlContentStr = urlContent.getContent().toString();
		String DilbertGif = "";
		// this is the actual parsing to get the url for the dilbert gif
		int i = urlContentStr.indexOf("\" ALT=\"Today's Comic\""); // this is width of our pic
		while(!urlContentStr.substring(i-1,i).equals("\"")) {
			DilbertGif = urlContentStr.substring(i-1,i) + DilbertGif;
			i--;
		}

		return contentService.getResponse(DilbertGif);
	}
}